package com.yl.auth.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.model.entity.TuiJianRen;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yl.auth.model.vo.TuiJianRenVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author L
 * @since 2023-06-20
 */
public interface TuiJianRenMapper extends BaseMapper<TuiJianRen> {
    Page<TuiJianRen> findAllConAndPage(Page<TuiJianRen> tuiJianRenPage,@Param("tuiJianRenVo") TuiJianRenVo tuiJianRenVo);

    @Select("select count(l.reference_id) reference from tuijianren t\n" +
            "left join laoren l on t.id = l.reference_id\n" +
            "group by t.id")
    List<Long> getReference();

    @Update("update tuijianren set reward = #{tuiJianRen.reward}")
    void updateByReward(@Param("tuiJianRen") TuiJianRen tuiJianRen);

    TuiJianRen getByIdTui(@Param("id") Integer id);
}
